const request = require('request');
const appid='wx58925cabd0e5f16d';//公钥(public_key)

module.exports = class extends think.Service {
/*
    构造函数，并定义实例化值key，secret
    constructor(key, secret) {
        super();
        this.key = key;
        this.secret = secret;
    }
     // 带参数的实例化
    const sms = think.service('sms', key, secret);
*/
    async getWxUserInfo(openid){
        let url='http://newwx.ompchina.net/api/oauth2/getuserinfo?appid='+appid+'&openid='+openid;
        // const body = await this.fetch(url, { method: 'POST', body: 'a=1' }).then(res => res.json());
        const body = await this.fetch(url, { method: 'GET', body: 'a=1' }).then(res => res.json());
        return body;
    }
};
